package com.mango.ch10;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class S2Pair implements WritableComparable<S2Pair> {
	private String _1;
	private String _2;

	public S2Pair() {
	}

	public S2Pair(String _1, String _2) {
		super();
		this._1 = _1;
		this._2 = _2;
	}

	public String get_1() {
		return _1;
	}

	public void set_1(String _1) {
		this._1 = _1;
	}

	public String get_2() {
		return _2;
	}

	public void set_2(String _2) {
		this._2 = _2;
	}

	@Override
	public void write(DataOutput out) throws IOException {
		// TODO Auto-generated method stub
		out.writeUTF(this._1);
		out.writeUTF(this._2);
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		// TODO Auto-generated method stub
		this._1 = in.readUTF();
		this._2 = in.readUTF();
	}

	@Override
	public String toString() {
		return _1 + "\t" + _2;
	}

	@Override
	public int compareTo(S2Pair ot) {
		// TODO Auto-generated method stub
		int com = this._1.compareTo(ot.get_1());
		if (com == 0) {
			return this._2.compareTo(ot.get_2());
		}
		return com;
	}

}
